import server from './http';
import qs from 'qs';
import url from './serverAPI.config';
 
//接口1方法
export function lunbo(data){
    return server({
        url: url.lunbo,
        method: 'get',
        dataType: "json",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
        params: data
    })
}
 
//接口2方法
export function postByCategory(data){
    return server({
        url: url.post.getByCategory,
        method: 'get',
        dataType: "json",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
        params: data
    })
}

//接口2方法
export function postByType(data){
    return server({
        url: url.post.getByType,
        method: 'get',
        dataType: "json",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
        params: data
    })
}

export function submit(data) {
	return server({
		url: url.post.submitPost,
		method: 'post',
		dataType: "json",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		data: qs.stringify(data)
	})
}

export function getCategory(data) {
	
	return server({
		url: url.getcategorys,
		method: 'get',
	    dataType: "json",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	    params: data
	});
}



export function login(data) {
	return server({
		url: url.login,
		method: 'post',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	    data: qs.stringify(data)
	});
}

export function allpost() {
	return server({
		url: url.post.postall,
		method:'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8"
	});
}

export function getype(data) {
	return server({
		url: url.category.getType,
		method:'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		params:data
	});
}

export function checkLogin() {
	return server({
		url: url.check,
		method:'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	});
}

export function logout() {
	return server({
		url: url.logout,
		method:'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	});
}

export function registry(data) {
	return server({
		url: url.registry,
		method:'post',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		data: qs.stringify(data)
	});
}

export function getuser() {
	return server({
		url: url.getuser,
		method: 'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8"
	});
}

export function datas() {
	return server({
		url: url.datas,
		method: 'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8"
	});
}

export function userInfoAdd(userinfo) {
	return server({
		url: url.userinfo.add,
		method:'post',
		dataType:'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		data: userinfo
	});
}

export function uploadHeadpic(image) {
	return server({
		url: url.upload.image,
		method: 'post',
		dataType: 'json',
		headers:{

 			'Content-type': 'multipart/form-data'

 		},
		data: image
	})
}

export function selfPost() {
	return server({
		url: url.post.self,
		method: 'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8"
	});
}

export function readPost(params) {
	return server({
		url: url.post.read,
		method: 'get',
	    dataType: "json",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	    params: params
	});
}

export function typeAll() {
	return server({
		url: url.types.all,
		method: 'get',
		dataType: 'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8"
	});
}

export function replyPost(data) {
	return server({
		url: url.post.reply,
		method: 'post',
		dataType:'json',
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		data: qs.stringify(data)
	});
}